import request from '@/utils/request2'
import dayjs from 'dayjs'
const getPassRain = (date = new Date()) => {
    const dateObj = dayjs(new Date(new Date().toUTCString()));
    let url = 'http://image.nmc.cn/product/2023/10/16/STFC/medium/SEVP_NMC_STFC_SFER_ER1_ACHN_L88_PB_20231016090000000.jpg';
    return request({
        'url': url,
        'methods': "GET"
    });
}

// const getRainItem = (date = dayjs()) => {
//     var dateObjA = dayjs(date);
//     var dateObj = dayjs(new Date(dateObjA.toUTCString()));
//     return {
//         time: dateObjA.format('YYYY年MM月DD日 hh时mm分'),
//         url: 'http://image.nmc.cn/product/' + dateObj.format('YYYY/MM/DD') + '/STFC/medium/SEVP_NMC_STFC_SFER_ER1_ACHN_L88_PB_' + dateObj.format('YYYYMMDDHH') + '0000000.jpg'
//     }
// }

const getPassRainList = ( hours = 24,date = new Date()) => {
    var list = [];
    var dateObjA = dayjs(date);
    var dateObj = dayjs(new Date(date.toUTCString())).subtract(8, 'hour');
    for (let i = 0; i < hours; i++) {
        let arr = {
            time: dateObjA.format('YYYY年MM月DD日 hh时00分'),
            url: 'http://image.nmc.cn/product/' + dateObj.format('YYYY/MM/DD') + '/STFC/medium/SEVP_NMC_STFC_SFER_ER1_ACHN_L88_PB_' + dateObj.format('YYYYMMDDHH') + '0000000.jpg'
        };
        list.push(arr);
        dateObjA = dateObjA.subtract(1, 'hour')
        dateObj=  dateObj.subtract(1,'hour')
    }
    return list;
}

export {getPassRainList}
